﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_RoyalItemControls : System.Web.UI.Page
    {
        private IRoyalItemControlBLL ctrlBLL = new RoyalItemControlBLL();
        private IRoyalItemHistoriesBLL hisBLL = new RoyalItemHistoriesBLL();

        private RadComboBox cmbYear, cmbEmployeeType;
        protected void Page_Load(object sender, EventArgs e)
        {
            cmbYear = (RadComboBox)cbYear.FindControl("cbYear");
            cmbEmployeeType = (RadComboBox)cbEmployeeType.FindControl("cbEmployeeType");

            if (!IsPostBack)
            {
                cbEmployeeType.ListEmployeeTypeComboBox();
                cbYear.ListYear();
                cmbYear.SelectedValue = Convert.ToString(Int32.Parse(DateTime.Today.Year.ToString()) + 543);

                LoadDataGrid();
            }
            LoadDataGrid();
        }
        public void LoadDataGrid()
        {
            IList<RoyalItemControlInfo> Info = ctrlBLL.GridRoyalItemControls();
            RadGrid1.DataSource = Info;   
            RadGrid1.DataBind();
        }

        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Sequence"]);
                ctrlBLL.Delete(seq, 1);
            }
            else if (e.CommandName == "SendAll")
            {
                //GridDataItem item;
                //for (int i = 0; i < EmployeeEducationEditGrid.Items.Count; i++)
                //{
                //    item = EmployeeEducationEditGrid.Items[i];
                //    if (item.Selected)
                //    {
                //        //string strPK = item.OwnerTableView.DataKeyValues[i]["edu_seq"].ToString();
                //        //edu.Delete(strPK, Session["UserID"].ToString(), DateTime.Now);
                //    }
                //}
            }

            LoadDataGrid();
        }

        protected void cmdFilter_Click(object sender, EventArgs e)
        {

        }    
        

    }
}
